#ifndef _PEDPRIVATE_H_
#define _PEDPRIVATE_H_


#define DC_CMD_CTRL_RES "\x11"
#define DC_CMD_EX_DUKPT_INIT  0x1011
#define DC_CMD_EX_DUKPT_GET_PIN  0x1012
#define DC_CMD_EX_DUKPT_GET_MAC  0x1013
#define SDK_DUKPT_KSN_LEN 10
#define SDK_DUKPT_KEY_LEN 16


#define  TMK_INDEX_AREA         0
#define  WK_INDEX_AREA          1

typedef struct _strInnerTKeyDEncryptPara
{
    const u8 *m_indata;
    u8 *m_outdata;
    u32 m_len;
} strInnerTKeyDEncryptPara;

typedef struct _strInnerHKeyDEncryptPara
{
    u32 m_area;
    u32 m_index;
    u32 m_half;
    const u8 *m_indata;
    u8 *m_outdata;
    u32 m_len;
} strInnerHKeyDEncryptPara;


#define PED_DATAOK                            0X20
#define PED_DATAERR                            0X2F
#define POS_PEDDISPSTR                                  0x76
#define PED_KEYINMONEY                    0X83
#define POS_CANCELKEY                        0X8C
#define POS_DOWNPOSNO                    0x9f
#define POS_PEDSAVEDATA                                     0x03
#define POS_PEDREADDATA                                     0x01
#define POS_GETPEDSN                                     0x04
#define POS_SETPEDLANGUAGE                          0x75
#define POS_UPLOADPARA                        0x9d
#define POS_DOWNLOADPARA                    0x9e
#define POS_ASK_VERSION                    0xBE
#define PED_ACK_VERSION                    0xB1
#define PED_ACK_VERSTAKE                    0xB9
#define POS_ASK_VERSTAKE                    0xBA
#define PED_DENCRYPTTAK                             0xE0
#define POS_TRADEAMOUNT                    0x8A
#define POS_BALANCE                        0x8E
#define POS_DECRYPTWK                          0xF9
#define PED_CHECKWK                        0xF2
#define POS_FLUSHWK                        0xF8
#define POS_PINMODE                        0xE9
#define PED_PINCODE                        0xE5
#define POS_ENCRYPTDATA                    0xFA
#define PED_ENCRYPTEDCODE                0xF0
#define POS_DECRYPTCODE                    0xED
#define PED_DECRYPTEDDATA                0xE8
#define POS_UPDATETMKMODE                0xEE
#define POS_UPDATEONETMK                0xFB
#define POS_UPDATEMULTITMK                0xFC
#define POS_FLUSHTMK                    0xEC
#define POS_DELETETMK                    0xEA
#define POS_CANCEL                        0x8C
#define PED_FLUSHWKERROR                0xF3
#define PED_FLUSHWKOK                    0xF4
#define PED_ENCRYPTERROR                0xF6
#define PED_DELETETMKOK                    0xE1
#define PED_DELETETMKERROR                0xE2
#define PED_PINCODERROR                    0xE4
#define POS_VERIFYAMOUNT                0xBB
#define PED_VERIFYAMOUNT                0xBC
#define PED_REQUESTRANDOM                0x82
#define POS_RANDOM                        0x8B
#define POS_DD_COMMAND                    0xDD
#define POS_DB_COMMAND                    0xDB
#define POS_DC_COMMAND                    0xDC
#define POS_NOPHRASEREMOTE                0xB0
#define POS_TDA8023                        0xA0
#define POS_INPUTAMT                                0x8d
#define PED_RESPONSEDATA                0x71
#define PED_CARDIN                        0x76
#define PED_CARDOUT                    0x77
#define PED_RESETDATA                    0x78
#define PED_RESETFAIL                    0x72
#define POS_RESETCARD                    0x7B
#define POS_OPERATECARD                0x7C
#define POS_MEMORY                      0xCA
#define PED_OPERATEEND                    0x7D
#define PED_CARDSTATE                0x73
#define POS_DOWNTMK                         0x69
#define POS_INITKEYIC                           0xfd
#define PED_INITKEYICOK                            0xf7

#define MODEMINIEX                      0x3D

#define MODEMCFGEXDAMAGE                0x35
#define REMOTEDOWNLOAD                  0x19
#define NOLINE                          0X33
#define ENGAGED                         0X34

#define POS_PCIMKDES                    0x20
#define POS_PCIWKDES                    0x21
#define POS_PCIWKE99                    0x22
#define POS_PCIMKFLUSH                    0x23
#define POS_PCIWKFLUSH                    0x24
#define POS_PCITMPDES                    0x25
#define POS_PCIWKE919                    0x26


#if 1
#define MK_DESTHRESHOLD             0
#define MK_3DESTHRESHOLD                102
#define WK_DESTHRESHOLD             0
#define WK_3DESTHRESHOLD                22

#define WK_DESTHRESHOLDEX           150
#define WK_3DESTHRESHOLDEX          44

#define WK_DESTHRESHOLD_DDI         0
#define WK_3DESTHRESHOLD_DDI            128


#define TPK_STORENO                 0x00
#define TAK_STORENO                 0x01
#define TPK_3DESSTORENO             (TPK_STORENO+WK_3DESTHRESHOLD)
#define TAK_3DESSTORENO             (TAK_STORENO+WK_3DESTHRESHOLD)

#define TPK_STORENOEX                   (TPK_STORENO+WK_DESTHRESHOLDEX)
#define TAK_STORENOEX                   (TAK_STORENO+WK_DESTHRESHOLDEX)
#define TPK_3DESSTORENOEX           (TPK_STORENO+WK_3DESTHRESHOLDEX)
#define TAK_3DESSTORENOEX           (TAK_STORENO+WK_3DESTHRESHOLDEX)


#define TPK_TEMPSTORENO             20
#define TAK_TEMPSTORENO             21
#define TPK_3DESTEMPSTORENO         (TPK_TEMPSTORENO+WK_3DESTHRESHOLD)
#define TAK_3DESTEMPSTORENO         (TAK_TEMPSTORENO+WK_3DESTHRESHOLD)

#define PCI_DESTEMPSTORENO          0
#define PCI_3DESTEMPSTORENO         16

#define DISPAGE1 0
#define DISPAGE2 1
#define DISPAGE3 2
#define DISPAGE4 3
#define DISPAGE5 4

typedef enum _PARSESTEP
{
    STEP_SOH = 0,
    STEP_FID,
    STEP_ORDER,
    STEP_LEN1,
    STEP_LEN2,
    STEP_DATA,
    STEP_ETX,
    STEP_BCC
} PARSESTEP;
#endif /* if 0 */

#define PED_SOH                         0x01
#define PED_ETX                          0x03

#define PED_KEY_TEXT                0X12
#define PED_KEY_ORDER            0X13
#define PED_KEY_TEXTEX           0x15

#define PED_SIM_TEXT            0x16
#define PED_SIM_ORDER            0x17
#define PED_SIM_TEXTEX            0x24


#define RECVBUFMAXLEN       1024
#define RECVCMDMAXNUM       5

typedef struct _RECVCFG
{
    u8 ucFrameId;
    //u8 ucCmd;
    u16 uiCmd;
    u8 ucStep;
    u8 ucBCC;
    u8 heRecvBuf[RECVBUFMAXLEN];
    u16 usLen;
    u16 usParseLen;
    //u8 heExpectRecvCmd[RECVCMDMAXNUM];
    u16 heuiExpectRecvCmd[RECVCMDMAXNUM];

    s32 iTimeOut;
} RECVCFG;

typedef struct _SENDCFG
{
    u8 ucCmd;
    u8 *pheSendBuf;
    u16 usLen;
} SENDCFG;

typedef struct _UARTCFG
{
    SENDCFG stSendData;
    RECVCFG stRecvData;
} UARTCFG;

#endif
